package cc.vv.baselibrary.util.router;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;

import java.util.ArrayList;

import cc.vv.baselibrary.global.BCIntentKey;
import cc.vv.baselibrary.location.LocationIntentKey;
import cc.vv.baselibrary.vFinal.BTParamKey;
import cc.vv.baselibrary.vFinal.IMIntentRequestKey;

/**
 * 路由跳转工具类
 * Created by sun.li on 2018/10/26.
 *
 * @author sun.li
 */

public class RouterIntentUtil {

    private static RouterIntentUtil mInstance;

    public static RouterIntentUtil getInstance() {
        if (null == mInstance) {
            synchronized (RouterIntentUtil.class) {
                if (null == mInstance) {
                    mInstance = new RouterIntentUtil();
                }
            }
        }
        return mInstance;
    }

    /**
     * 跳转应用主界面
     */
    public void intentAppMainActivity(Context mContext) {
        if (null != mContext) {
            Intent intent = RouterTransferCenterUtil.getInstance().getRouterIntent(mContext,
                    RouterActivityIntentResourceKey.KEY_MODULE_APP_MAIN);
            if (null != intent) {
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                mContext.startActivity(intent);
            }
        }
    }

    /**
     * 跳转应用主界面
     */
    public void intentLoginActivity(Context mContext) {
        if (null != mContext) {
            Intent intent = RouterTransferCenterUtil.getInstance().getRouterIntent(mContext,
                    RouterActivityIntentResourceKey.KEY_MODULE_LOGIN);
            if (null != intent) {
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                mContext.startActivity(intent);
            }
        }
    }

    /**
     * 跳转应用主界面
     */
    public void intentLoginActivity(Context mContext, Boolean outLine) {
        if (null != mContext) {
            Intent intent = RouterTransferCenterUtil.getInstance().getRouterIntent(mContext,
                    RouterActivityIntentResourceKey.KEY_MODULE_LOGIN);
            if (null != intent) {
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.putExtra(BCIntentKey.OUT_LINE, outLine);
                mContext.startActivity(intent);
            }
        }
    }


    /**
     * 跳转查看大图界面
     */
    public void intentImageWatcherActivity(Context mContext, ArrayList<String> urls, int position) {
        if (null != mContext && null != urls && urls.size() > 0) {
            Intent routerIntent = RouterTransferCenterUtil.getInstance().getRouterIntent(mContext,
                    RouterActivityIntentResourceKey.KEY_BT_IMAGE_WATCHER_ACTIVITY);
            if (null != routerIntent) {
                routerIntent.putExtra(BTParamKey.INTENT_IMGS_URLS, urls);
                routerIntent.putExtra(BTParamKey.INTENT_IMGS_POSITION, position);
                RouterTransferCenterUtil.getInstance().routerStartActivity(mContext, routerIntent);
            }
        }
    }
}
